﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ChatClient
{
    class ChatRoomPage : TabPage
    {
        // Private members

        ChatInterfaceItem m_chatItem;
        String m_roomName;

        // Constructor

        public ChatRoomPage(String roomName, String username, IOutgoingMessageHandler messageHandler)
        {
            m_chatItem = new ChatInterfaceItem(this, 0, 0, Width, Height, roomName, username, messageHandler);

            this.Text = roomName;
            this.Resize += new EventHandler((object sender, EventArgs e) =>
                {
                    m_chatItem.Size = this.Size;
                });

            m_roomName = roomName;
        }

        // Public methods

        public void OnIncomingMessage(String sender, String message)
        {
            m_chatItem.PostIncomingMessage(sender, message);
        }

        public void OnOutgoingMessage(String message)
        {
            m_chatItem.PostOutgoingMessage(message);
        }

        public String GetRoomName()
        {
            return m_roomName;
        }
    }
}
